﻿using System.Collections.Generic;
using JSAnalyse.Core;
using JSAnalyse.Test.Helper;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace JSAnalyse.Test
{
    /// <summary>
    /// This is a test class for testContextInstance and is intended
    /// to contain all testContextInstance Unit Tests
    /// </summary>
    [TestClass]
    public class JQueryFileTest
    {
        /// <summary>
        /// A simple dependency check test
        /// </summary>
        [TestMethod]
        public void JQueryFileDependencyTest()
        {
            var jqueryFile = "jquery-1.7.js";
            var jqueryTestScriptFile = "JQueryTestScript.js";

            var allowedDependencies = new List<AllowedDependencyTest>();

            var jqueryFileInfo = new JavascriptFileInfo(jqueryFile);
            var jqueryTestScriptFileInfo = new JavascriptFileInfo(jqueryTestScriptFile);

            var dependencyRunner = new DependencyRunner(
                new List<JavascriptFileInfo> { jqueryFileInfo, jqueryTestScriptFileInfo },
                new AllowedDependenciesTest(allowedDependencies)
                );

            var result = dependencyRunner.Start();
            var jqueryResult = GeneralHelper.GetResultItem(result, jqueryFile);
            var jqueryTestScriptResult = GeneralHelper.GetResultItem(result, jqueryTestScriptFile);
            Assert.AreEqual(2, result.Count);

            Assert.IsNotNull(jqueryResult);
            Assert.AreEqual(0, jqueryResult.WrongFileDependencies.Count);

            Assert.IsNotNull(jqueryTestScriptResult);
            Assert.AreEqual(1, jqueryTestScriptResult.WrongFileDependencies.Count);
        }


    }
}
